<?php 
echo $this->element('reportcss'); 
$cuser=$session->read('User');
$file_name = "企业统计情况总表";
if(empty($report)){?>
<div class="right_side_operate_area">
	<div class="right_side_title left">
		<h2><?php echo $file_name;?></h2>
	</div>
	<?php  
		if($showpage==1) {
			if(isset($paging)){ echo $this->renderElement('pagination',$paging);} 
		}
		$url_explode=explode("group=", $_SERVER["QUERY_STRING"]);
    	echo '<div class="right back_btn">';
    	if(!empty($industry))
			echo $html->link("导出报表","/reports/index/".$sortBy."/".$direction."/1?industry=".$industry."&group=".$url_explode[1]);
		else 
			echo $html->link("导出报表","/reports/index/".$sortBy."/".$direction."/1group=".$url_explode[1]);
		echo '</div>';
	?>
	<?php echo $this->element('reportgroup'); ?>
	<div class="right search_box">
		<form onsubmit="return searchcompany()">
	    	<div class="left search_text">
	    		<?php echo $form->text('company.keyword',array('placeholder'=>'搜索企业名称','value'=>$keyword, 'id'=>'search', 'class'=>'text_box'));?>
	    	</div>
	        <div class="left search_btn"><input type="submit" value=""/></div>
        </form>
        <div class="clear"></div>
    </div>
    <div class="term_choose_area right">
    	<a class="term_choose_btn" id="term_choose_btn" title="选择"></a>
    	<div class="screen_list" id="screen_list" style="display:none;visibility:hidden;">
    		<ul>
    			<?php 
    			foreach($industrys as $key=>$strindustry){
    				$selected="";
    				if($industry==$key){
    					$selected="selected";
    				}
    				echo '<li class="'.$selected.'">';
    				echo $html->link($strindustry,"javascript:void(0)",array("onclick"=>"return setindustry('".$key."')","class"=>$selected));
    				echo '</li>';
    			}
    			?>
    		</ul>
    		<div id="industry" style="display:none"><?php echo $industry?></div>
    	</div>
    </div>
    
    <div class="clear"></div>
</div>
<div class="right_side_scollbar">
    <div class="detail_info_panel">
        <div class="items_list">
<?php }?>
        	<?php 
       			$upimg=$html->image("up.png");
				$downimg=$html->image("down.png");
				$capitalimg=$capitalsort=="desc"?$upimg:$downimg;
				$regimg=$regsort=="desc"?$upimg:$downimg;
				if(!empty($report)){
					echo "<div align='center'><h3>企业统计情况总表</h3></div>";
				}
			?>
        	<table border='1'>
            	<tr>
            		<th>序号</th>
                    <th>企业名称</th>
                    <th>模块</th>
                    <th>负责人</th>
                    <th>联系电话</th>
                    <?php 
                    	if(!empty($report)){
	                    	echo "<th>注册资金（万）</th>";
	                    	echo "<th>注册时间</th>";
                    	}else{
	                    	echo "<th>".$html->link('注册资金（万）'.$capitalimg,'javascript:void(0)',array('onclick'=>"return setsort('/capital/$capitalsort')",'escape' => false))."</th>";
	                 		echo "<th>".$html->link('注册时间'.$regimg,'javascript:void(0)',array('onclick'=>"return setsort('/reg_time/$regsort')",'escape' => false))."</th>";
                    	}
                    ?>
                </tr>
                <?php 
                $i=1;
				foreach($companys as $company){
					$id=$company["Company"]["id"];
					$company_name=$company["Company"]["company_name"];
					$groupname = $grouplist[$company["Company"]["groupid"]];
					
					echo "<tr>";
					echo "<td align='center'>".(($limit*($page-1))+$i)."</td>";
					$i++;
					if(!empty($report)){
						echo "<td align='center'>".$company_name."</td>";
					}else{
						echo "<td>".$html->link($str->sub_len($company_name,20),"/reports/showcompinfo/".$id,array("title"=>$company_name),null)."</td>";
					}
					echo "<td align='center'>".$groupname."</td>";
					echo "<td align='center'>".$str->formatquantity($company["Company"]["contact"])."</td>";
					echo "<td align='center'>".$str->formatquantity($company["Company"]["tel"])."</td>";
					$cap_type=$company["Company"]["cap_type"]=="0"?"￥":"＄";
					echo "<td align='center'>".$cap_type.$company["Company"]["capital"]."</td>";
					$reg_time=$company["Company"]["reg_time"];
					if(!empty($reg_time)){
						$reg_time=date("Y-m-d",strtotime($reg_time));
					}else{
						$reg_time = $str->formatquantity($reg_time);
					}
					echo "<td align='center'>".$reg_time."</td>";
					echo "</tr>";
				}?>
            </table>
<?php if(empty($report)){?>
		</div>
    </div>
</div>
<?php echo $this->element('autocomplete',array("model_name"=>"Company","field_name"=>"company_name","widget_name"=>"search_company")) ?>
<div id="sort" class="txthide"><?php echo '/'.$sortBy.'/'.$direction?></div>
<script>
if($("#search").val()!=""){
	$("#search").focus();
}
function setindustry(inid){
	$("#industry").html(inid);
	return searchcompany();
}
function setsort(sort){
	$("#sort").html(sort);
	return searchcompany();
}
function searchcompany()
{	
	var sort=$("#sort").html();
	var webpath=$("#getpath").attr('href');
	var urlpath=webpath+"reports/index"+sort+"?seach=all";
	var inid=$("#industry").html();
	var search=$("#search").val();
	if(inid=="" && search==""){
		location.href=urlpath;
	}else{
		if(inid.trim()!=""){
			urlpath+="&industry="+inid.trim();
		}
		if(search.trim()!=""){
			urlpath+="&keyword="+encodeURIComponent(search.trim());
		}
		location.href=urlpath;
	}
	return false;
}
function focuseEV(C,B,A){
	if(window.attachEvent){
		C.attachEvent("on"+B,A);
	}else{
		if(window.addEventListener){
			C.addEventListener(B,A,false);
		}
	}
}
focuseEV(document,"click",function(E){
	var E=E||window.event;
	var A=E.target||E.srcElement;
	var D=window.event?E.button:E.which;
	var C=G("term_choose_btn"),B=G("screen_list");
	while(A&&A!=document.body&&A.tagName.toLowerCase()!="html"){
		if(A==C){break}
		if(A==B){break}
		A=A.parentNode
	}
	if(A==B){
	}else if(A!=C){
		B.style.display="none"
			B.style.visibility="hidden"
	}else{
		if(D<2){
			B.style.display=B.style.display=="block"?"none":"block";
			B.style.visibility=B.style.visibility=="hidden"?"visible":"hidden";
		}
	}
});
funPlaceholder(document.getElementById("search"));
</script>
<?php } ?>